package com.lc.luzhengtang.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.lc.luzhengtang.BaseApplication;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.base.BaseActivity;
import com.lc.luzhengtang.bean.CommentList;
import com.lc.luzhengtang.conn.ConnCommentList;
import com.lc.luzhengtang.util.MySection;
import com.zcx.helper.http.AsyCallBack;

import java.util.List;

/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class SectionUseActivity extends BaseActivity {
    private RecyclerView mRecyclerView;
    private List<MySection> mData;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_section_uer);

        setTitle("Section Use");
        mRecyclerView = (RecyclerView) findViewById(R.id.rv_list);
//        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));


        new ConnCommentList(BaseApplication.basePreferences.readUid(), 1, new AsyCallBack<CommentList>() {
            @Override
            public void onStart(int type) throws Exception {
                super.onStart(type);
                showLoading();
            }

            @Override
            public void onSuccess(String toast, int type, Object o, CommentList commentList) throws Exception {
                super.onSuccess(toast, type, o, commentList);
                //   mData = DataServer.getSampleData();

                // mData = commentList.getData();
                //  sectionAdapter = new SectionAdapter(R.layout.item_section_content, R.layout.def_section_head, mData);
                // rvList.setAdapter(sectionAdapter);
//                List<CommentList.DataBean> dataBeanList = new ArrayList<CommentList.DataBean>();
//                dataBeanList = commentList.getData();
                //  mData = commentList.getData();
//                sectionAdapter = new SectionAdapter(R.layout.item_section_content, R.layout.def_section_head, dataBeanList);
                //   SectionAdapter sectionAdapter = new SectionAdapter(R.layout.item_section_content, R.layout.def_section_head, dataBeanList);
               /* mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {
                    @Override
                    public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
                        MySection mySection = mData.get(position);
                        if (mySection.isHeader)
                            Toast.makeText(SectionUseActivity.this, mySection.header, Toast.LENGTH_LONG).show();
                        else
                            Toast.makeText(SectionUseActivity.this, mySection.t.getName(), Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                        Toast.makeText(SectionUseActivity.this, "onItemChildClick" + position, Toast.LENGTH_LONG).show();
                    }


                });*/
                //    mRecyclerView.setAdapter(sectionAdapter);
            }

            @Override
            public void onFail(String toast, int type) throws Exception {
                super.onFail(toast, type);
            }

            @Override
            public void onEnd(String toast, int type) throws Exception {
                super.onEnd(toast, type);
                dismissLoading();
            }
        }


        ).execute(SectionUseActivity.this, false);




  /*  SectionAdapter sectionAdapter = new SectionAdapter(R.layout.item_section_content, R.layout.def_section_head, mData);
        mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {

            @Override
            public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
                MySection mySection = mData.get(position);
                if (mySection.isHeader)
                    Toast.makeText(SectionUseActivity.this, mySection.header, Toast.LENGTH_LONG).show();
                else
                    Toast.makeText(SectionUseActivity.this, mySection.t.getName(), Toast.LENGTH_LONG).show();
            }

            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                Toast.makeText(SectionUseActivity.this, "onItemChildClick" + position, Toast.LENGTH_LONG).show();
            }


        });
        mRecyclerView.setAdapter(sectionAdapter);*/
    }


}
